package com.thread.demo;

public class RunnableDemo implements Runnable{
	@Override
	public void run() {
		// 必须重新实现run方法
		String name = Thread.currentThread().getName();
		if(name == "001") {
			System.out.println("execute database search: "+ name);
		}
		if(name == "002") {
			System.out.println("execute net : "+ name);
		}
		if(name == "003") {
			System.out.println("run able name is: "+ name);
		}
		
	}
	public static void main(String[] args) {
		RunnableDemo runnableDemo = new RunnableDemo();
		Thread td1 = new Thread(runnableDemo,"001");
		Thread td2 = new Thread(runnableDemo,"002");
		Thread td3 = new Thread(runnableDemo,"003");
		sleepTd(td1, 3);
		td1.start();
		sleepTd(td2, 3);
		td2.start();
		sleepTd(td3, 3);
		td3.start();	
	}
	private static void sleepTd(Thread td,int duration) {
		try {
			System.out.println("休息一会儿：");
			td.sleep(1000*duration);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	private static void notifyTd(Thread td) {
		// TODO Auto-generated method stub

	}

}
